/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Kernel;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;
import edu.pku.sei.modeler.uml.util.MetaTypedSet;



/**
 * @generated
 * modified by zsj
 *
 */
public class PackageImport extends DirectedRelationship implements IPackageImport {
	// attributes
	
	protected VisibilityKind visibility;
	
	
	
	
	// references
	
	protected MetaTypedList importedPackage;
	
	
	public PackageImport(){
		super();
		this.visibility = new VisibilityKind();
	}
	// getters & setters for attributes
	
	public VisibilityKind getVisibility() {
		return visibility;
	}
	public void setVisibility(VisibilityKind newVisibility) {
		VisibilityKind oldvisibility = visibility;
		visibility = newVisibility;
		firePropertyChange(ModelPackage.PACKAGEIMPORT_VISIBILITY, oldvisibility, newVisibility);
	}
	
	// getters for references
	
	public MetaTypedList getImportedPackage() {
		if(importedPackage == null) {
			importedPackage = new MetaTypedSet(UMLPackage.class, this, ModelPackage.PACKAGEIMPORT_IMPORTEDPACKAGE);
		}
		return importedPackage;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		
		if (this.visibility != null) {
			XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.PACKAGEIMPORT_VISIBILITY, this.visibility.getEnumName());
		}
		
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.PACKAGEIMPORT_IMPORTEDPACKAGE, importedPackage);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		visibility = new VisibilityKind(XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.PACKAGEIMPORT_VISIBILITY));
		
		// references
		
		this.getImportedPackage().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.PACKAGEIMPORT_IMPORTEDPACKAGE, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.PACKAGEIMPORT_VISIBILITY.equals(featureID)) {
			visibility = (VisibilityKind)value;
		}
		
		// references
		
		else if(ModelPackage.PACKAGEIMPORT_IMPORTEDPACKAGE.equals(featureID)) {
			getImportedPackage().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 